<%@ Page Title="Questionnaire" Language="C#" MasterPageFile="~/Views/Shared/Application.Master" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	Questionnaire
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

<% using (Html.BeginForm("Questionnaire, Questionnaire"))
   { %>

    <h2>Questionnaire</h2>
    
    <h3>Please answer each question honestly. When you have selected your answer or typed it in, click "Next" to continue.</h3>    
    
    <br />
    <br />
    
    <% if (Session["idx"] != null)
       { %>
        <%= ((DomainModel.Entities.Question)ViewData["question"]).QuestionString %>
        <input id="QuestionID" name="QuestionID" type="hidden" value="<%= ((DomainModel.Entities.Question)ViewData["question"]).QuestionID %>" />
    
    <br />
        <% if (((DomainModel.Entities.Question)ViewData["question"]).Question_Type == 0)
           { %>
            <% foreach (DomainModel.Entities.Answer answer in ((List<DomainModel.Entities.Answer>)ViewData["answers"]))
               { %>
                    <% if ((TempData["previousAnswer"] != null) && (answer.AnswerID == ((DomainModel.Entities.AnsweredQuestion)TempData["previousAnswer"]).AnswerID))
                       { %>
                            <input name="AnswerRadios" type="radio" value="<%= answer.AnswerID %>" checked="checked" /><%= answer.QAnswer%><br />
                    <% }
                       else
                       { %>
                            <input name="AnswerRadios" type="radio" value="<%= answer.AnswerID %>" /><%= answer.QAnswer%><br />
                    <% } %>
            <% } %>
        <% }
           else
           { %>
                <% if ((TempData["previousAnswer"] != null) && ((List<DomainModel.Entities.Answer>)ViewData["answers"]).First().AnswerID == ((DomainModel.Entities.AnsweredQuestion)TempData["previousAnswer"]).AnswerID)
                   { %>
                        <input id="AnswerTextBox" name="AnswerTextBox" type="text"  value="<%= ((DomainModel.Entities.AnsweredQuestion)TempData["previousAnswer"]).TextAnswer %>" size="100" />
                <% } 
                   else 
                   { %>           
                        <input id="AnswerTextBox" name="AnswerTextBox" type="text" />
                <% } %>
                <input id="AnswerID" name="AnswerID" type="hidden" value="<%= ((List<DomainModel.Entities.Answer>)ViewData["answers"]).First().AnswerID %>" />
        <% } %>
    <% } %>
     
    <br />
    <br />
    
    <input id="BackButton" name="back" type="submit" value="Back" />&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp
    <input id="NextButton" name="next" type="submit" value="Next" /> 
    
<% } %>
</asp:Content>

